package jerry.cn.rfid_module.Setting.Fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import jerry.cn.rfid_module.R;
import jerry.cn.rfid_module.Setting.Adapter.MainListAdapter;
import zuo.biao.library.base.BaseListFragment;
import zuo.biao.library.interfaces.AdapterCallBack;
import zuo.biao.library.model.Entry;

public class MainListFragment extends BaseListFragment<Entry<String, String>, ListView, MainListAdapter> {

    public static MainListFragment createInstance() {
        return new MainListFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        setContentView(R.layout.fragment_mainlist);

        //功能归类分区方法，必须调用<<<<<<<<<<
        initView();
        initData();
        initEvent();
        //功能归类分区方法，必须调用>>>>>>>>>>

        onRefresh();

        return view;//返回值必须为view
    }

    @Override
    public void setList(final List<Entry<String, String>> list) {
        //示例代码<<<<<<<<<<<<<<<
        setList(new AdapterCallBack<MainListAdapter>() {

            @Override
            public void refreshAdapter() {
                adapter.refresh(list);
            }

            @Override
            public MainListAdapter createAdapter() {
                return new MainListAdapter(context);
            }
        });
        //示例代码>>>>>>>>>>>>>>>
    }


    @Override
    public void getListAsync(int page) {
        showProgressDialog(R.string.loading);

        List<Entry<String, String>> list = new ArrayList<Entry<String, String>>();
        list.add(new Entry<String, String>(getString(R.string.ReaderList),String.valueOf(R.drawable.reader_list)));
        list.add(new Entry<String, String>(getString(R.string.Antenna),String.valueOf(R.drawable.antenna)));
        list.add(new Entry<String, String>(getString(R.string.SingulationControl),String.valueOf(R.drawable.singulationcontrol)));
        list.add(new Entry<String, String>(getString(R.string.startstopTriggers),String.valueOf(R.drawable.startstoptriggers)));
        list.add(new Entry<String, String>(getString(R.string.Regulatory),String.valueOf(R.drawable.regulatory)));
        list.add(new Entry<String, String>(getString(R.string.Battery),String.valueOf(R.drawable.battery)));
        list.add(new Entry<String, String>(getString(R.string.PowerManagement),String.valueOf(R.drawable.power_management)));
        list.add(new Entry<String, String>(getString(R.string.Beeper),String.valueOf(R.drawable.beeper)));

        onLoadSucceed(page, list);
    }
}
